import { listProjectsApi } from "@/api/sunnyproject";
import type { SunnyProject } from "@/types/sunnyProject/type";
import { defineStore } from "pinia";
import { ref } from "vue";

export const useProjectStore = defineStore("project", () => {
  const selectedProject = ref<SunnyProject>({
    id: -1,
    name: "请选择项目",
    proDesc: "",
    stepCount: 0,
    caseCount: 0,
    moduleList: "",
  });

  const projectList = ref<SunnyProject[]>([]);

  function listProjects() {
    listProjectsApi().then(({ data }) => {
      projectList.value = data;
    });
  }

  return { selectedProject, projectList, listProjects };
});
